package com.gf.gf_data.temp.dao;

import com.gf.gf_data.temp.entity.Account;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface AccountMapper {
    @Delete({
        "delete from _account",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into _account (id, phone, ",
        "area_code, password, ",
        "name, role, salt, ",
        "status, update_time, ",
        "reg_time)",
        "values (#{id,jdbcType=BIGINT}, #{phone,jdbcType=VARCHAR}, ",
        "#{areaCode,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{role,jdbcType=VARCHAR}, #{salt,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{regTime,jdbcType=TIMESTAMP})"
    })
    int insert(Account record);

    int insertSelective(Account record);

    @Select({
        "select",
        "id, phone, area_code, password, name, role, salt, status, update_time, reg_time",
        "from _account",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    Account selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Account record);

    @Update({
        "update _account",
        "set phone = #{phone,jdbcType=VARCHAR},",
          "area_code = #{areaCode,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "role = #{role,jdbcType=VARCHAR},",
          "salt = #{salt,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "reg_time = #{regTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Account record);
}